/**
 * 
 */
package org.jenkon.iterator;

import java.util.Iterator;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * @author Jens Konopka
 * 
 */
public class NodeListIterator implements Iterator<Node> {

	private final NodeList nodeList;
	private int position = -1;

	/**
	 * @param nodeList
	 *            {@link NodeList}
	 */
	public NodeListIterator(final NodeList nodeList) {
		this.nodeList = nodeList;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.Iterator#hasNext()
	 */
	public boolean hasNext() {
		return position < nodeList.getLength() - 1;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.Iterator#next()
	 */
	public Node next() {
		return nodeList.item(++position);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.Iterator#remove()
	 */
	public void remove() {
		throw new UnsupportedOperationException("remove is not supported");
	}

}
